<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <j-form-container :disabled="disableSubmit">
        <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
          <a-row>
            <!-- <a-col :span="8">
              <a-form-model-item label="项目id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectId">
                <a-input v-model="model.projectId" placeholder="请输入项目id"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="招标项目编号"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="tenderProjectCode"
              >
                <a-input v-model="model.tenderProjectCode" placeholder="请输入招标项目编号"></a-input>
              </a-form-model-item>
            </a-col> -->
            <a-col :span="8">
              <a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bidSectionCode">
                <a-input v-model="model.bidSectionCode" placeholder="请输入编号"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bidSectionName">
                <a-input v-model="model.bidSectionName" placeholder="请输入名称"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="分类"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="tenderProjectClassifyCode"
              >
                <j-category-select ref="sectionTypeRef" v-model="model.tenderProjectClassifyCode" pcode="标段分类" />
              </a-form-model-item>
            </a-col>
            <!-- <a-col :span="8">
              <a-form-model-item
                label="招标项目标识码 (guid)"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="tenderProjectId"
              >
                <a-input v-model="model.tenderProjectId" placeholder="请输入招标项目标识码 (guid)"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="原标段（包）标识码 (guid)"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="oldbidSectionId"
              >
                <a-input v-model="model.oldbidSectionId" placeholder="请输入原标段（包）标识码 (guid)"></a-input>
              </a-form-model-item>
            </a-col> -->
            <!-- <a-col :span="8">
              <a-form-model-item
                label="标段（包）状态 (暂停-1、终止-2)"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="iszhongzhi"
              >
                <a-input v-model="model.iszhongzhi" placeholder="请输入标段（包）状态 (暂停-1、终止-2)"></a-input>
              </a-form-model-item>
            </a-col> -->
            <!-- <a-col :span="8">
              <a-form-model-item
                label="暂停/终止原因"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="zhongzhiInfo"
              >
                <a-input v-model="model.zhongzhiInfo" placeholder="请输入暂停/终止原因"></a-input>
              </a-form-model-item>
            </a-col> -->
            <a-col :span="8">
              <a-form-model-item
                label="监督部门名称"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="superviseDeptName"
              >
                <a-input v-model="model.superviseDeptName" placeholder="请输入监督部门名称"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="监督部门代码"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="superviseDeptCode"
              >
                <a-input v-model="model.superviseDeptCode" placeholder="请输入监督部门代码"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="24">
              <a-form-model-item
                label="内容"
                :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                :wrapperCol="{ lg: { span: 21 }, sm: { span: 20 } }"
                prop="bidSectionContent"
              >
                <a-textarea v-model="model.bidSectionContent" rows="2" placeholder="请输入内容" />
              </a-form-model-item>
            </a-col>

            <!-- <a-col :span="8">
              <a-form-model-item
                label="标段（包）内容"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="bidSectionContent"
              >
                <a-input v-model="model.bidSectionContent" placeholder="请输入标段（包）内容" type="textarea" :rows="1"></a-input>
              </a-form-model-item>
            </a-col> -->

            <a-col :span="8">
              <a-form-model-item
                label="合同估算价(万元)"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="contractReckonPrice"
              >
                <a-input-number
                  v-model="model.contractReckonPrice"
                  placeholder="请输入合同估算价(万元)"
                  style="width: 100%"
                />
              </a-form-model-item>
            </a-col>
            <!-- <a-col :span="8">
              <a-form-model-item
                label="标段合同估算价币种代码"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="currencyCode"
              >
                <a-input v-model="model.currencyCode" placeholder="请输入标段合同估算价币种代码"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="标段合同估算价单位"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="priceUnit"
              >
                <a-input v-model="model.priceUnit" placeholder="请输入标段合同估算价单位"></a-input>
              </a-form-model-item>
            </a-col> -->
            <a-col :span="24">
              <a-form-model-item
                label="投标人资格条件"
                :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                :wrapperCol="{ lg: { span: 21 }, sm: { span: 20 } }"
                prop="bidQualification"
              >
                <a-textarea v-model="model.bidQualification" rows="2" placeholder="请输入投标人资格条件" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="计划开工日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="beginDate">
                <j-date
                  placeholder="请选择计划开工日期"
                  v-model="model.beginDate"
                  style="width: 100%"
                  dateFormat="YYYY-MM-DD HH:mm:ss"
                  :showTime="true"
                />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="工期 (单位：天)"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="limiteTime"
              >
                <a-input-number v-model="model.limiteTime" placeholder="请输入工期" style="width: 100%" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="计划发包时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bidDate">
                <j-date
                  placeholder="请选择计划发包时间"
                  v-model="model.bidDate"
                  style="width: 100%"
                  dateFormat="YYYY-MM-DD HH:mm:ss"
                  :showTime="true"
                />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="是否网上招投标"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="isWebBidding"
              >
                <j-dict-select-tag
                  type="radio"
                  v-model="model.isWebBidding"
                  dictCode="yn"
                  placeholder="请选择是否网上招投标"
                />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="统一交易标识码"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="unifiedDealCode"
              >
                <a-input v-model="model.unifiedDealCode" placeholder="请输入统一交易标识码"></a-input>
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item
                label="交易系统标识码"
                :labelCol="labelCol"
                :wrapperCol="wrapperCol"
                prop="platformCode"
              >
                <a-input v-model="model.platformCode" placeholder="请输入交易系统标识码"></a-input>
              </a-form-model-item>
            </a-col>

            <a-col :span="24">
              <a-form-model-item
                label="附件"
                :labelCol="{ lg: { span: 3 }, sm: { span: 3 } }"
                :wrapperCol="{ lg: { span: 21 }, sm: { span: 20 } }"
                prop="attachmentCode"
              >
                <j-upload v-model="model.attachmentCode"></j-upload>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </j-form-container>
    </a-spin>
  </j-modal>
</template>

<script>
import { httpAction } from '@/api/manage'
import { randomUUID } from '@/utils/util'
export default {
  name: 'GcProjectEntrySectionModal',
  components: {},
  data() {
    return {
      title: '',
      width: 1500,
      visible: false,
      disableSubmit: false,

      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 9 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 },
      },
      confirmLoading: false,
      validatorRules: {
        projectId: [{ required: true, message: '请输入项目id!' }],
        tenderProjectCode: [{ required: true, message: '请输入招标项目编号!' }],
        bidSectionCode: [{ required: true, message: '请输入标段（包）编号!' }],
        bidSectionName: [{ required: true, message: '请输入标段（包）名称!' }],
        // tenderProjectId: [{ required: true, message: '请输入招标项目标识码 (guid)!' }],
        // superviseDeptName: [{ required: true, message: '请输入监督部门名称!' }],
        // superviseDeptCode: [{ required: true, message: '请输入监督部门代码!' }],
        // unifiedDealCode: [{ required: true, message: '请输入统一交易标识码!' }],
        // bidSectionContent: [{ required: true, message: '请输入标段（包）内容!' }],
        // tenderProjectClassifyCode: [{ required: true, message: '请输入标段（包）分类代码!' }],
        // bidQualification: [{ required: true, message: '请输入投标人资格条件!' }],
        // platformCode: [{ required: true, message: '请输入交易系统标识码!' }],
        // bidDate: [{ required: true, message: '请输入计划发包时间!' }],
        // isWebBidding: [{ required: true, message: '请输入是否网上招投标!' }],
      },
      url: {
        add: '/exSection/exSection/add',
        edit: '/exSection/exSection/edit',
        queryById: '/exSection/exSection/queryById',
      },
    }
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  methods: {
    add() {
      this.visible = true
      var obj = this.modelDefault
      obj.id = randomUUID()
      this.edit(obj)
    },
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      // 触发表单验证
      this.$refs.form.validate((valid) => {
        if (valid) {
          that.model.bdType = that.$refs.sectionTypeRef.treeValue[0].label
          that.$emit('ok', that.model)
          that.visible = false
        }
      })
    },
    handleCancel() {
      this.close()
    },
  },
}
</script>
